import {createRouter, createWebHistory} from 'vue-router'
import LoginView from '../views/LoginView.vue'
import UserListView from '../views/UserListView.vue'
import UserPermissionView from '../views/UserPermissionView.vue'
import ValueSetListView from '../views/ValueSetListView.vue'
import ResourceListView from '../views/ResourceListView.vue'
import RoleListView from '../views/RoleListView.vue'
import SocketTest from '../views/SocketTest.vue'
import CosTest from '../views/CosTest.vue'
import AppPage404 from '../views/AppPage404.vue'
import beforeEach from './before.each'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: 'root',
      redirect: 'login',
      meta: {
        noToken: true,
        hideNav: true,
        hideAside: true,
        title: '登录',
      },
    },
    {
      path: '/login',
      name: 'login',
      component: LoginView,
      meta: {
        noToken: true,
        hideNav: true,
        hideAside: true,
        title: '登录',
      },
    },
    {
      path: '/userList',
      name: 'userList',
      component: UserListView,
    },
    {
      path: '/userPermission',
      name: 'userPermission',
      component: UserPermissionView,
    },
    {
      path: '/valueSetList',
      name: 'valueSetList',
      component: ValueSetListView,
    },
    {
      path: '/resourceList',
      name: 'resourceList',
      component: ResourceListView,
    },
    {
      path: '/roleList',
      name: 'roleList',
      component: RoleListView,
    },
    {
      path: '/jjhAdmin/jjhNews',
      name: 'jjhNews',
      component: () => import('@/views/jjh/NewsView.vue'),
    },
    {
      path: '/socketTest',
      name: 'socketTest',
      component: SocketTest,
      meta: {
        noToken: true,
      },
    },
    {
      path: '/cosTest',
      name: 'cosTest',
      component: CosTest,
      meta: {
        noToken: true,
      },
    },
    {
      path: '/:catchAll(.*)',
      name: '*',
      component: AppPage404,
    },
  ],
})

beforeEach(router)

export default router
